﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class PopContent : MonoBehaviour
{
    Text content;
    [HideInInspector]
    public RectTransform rect;
    [HideInInspector]
    public Image img;
    // Start is called before the first frame update
    void Awake()
    {
        content = GetComponentInChildren<Text>();
        rect = GetComponent<RectTransform>();
        img = GetComponent<Image>();
    }

    private void OnEnable()
    {
        rect.anchoredPosition = new Vector3(0, 70f, 0);
        //Debug.Log(transform.localPosition);
        img.DOFade(1f, 0.5f);
        content.DOFade(1f, 0.5f);
        rect.DOBlendableLocalMoveBy(new Vector2(0, 20f),0.5f);
        content.text = "测试";
    }

    public void SetContent(string content)
    {
        //this.content.text = content;
        this.content.DOText(content, content.Length * 0.01f, true);
    }

    public void Exit()
    {
        img.DOFade(0f, 0.5f);
        content.DOFade(0f, 0.5f);
        rect.DOBlendableLocalMoveBy(new Vector2(0, 20f), 0.5f);
    }

    private void OnDisable()
    {
        Debug.Log("隐藏提示");
    }
}
